package org.lboot.flow.module.event;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.lboot.jpa.entity.BaseEntity;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Map;

/**
 * 流程自定义事件
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@Table(name = "flow_custom_event")
@ApiModel(value = "流程自定义事件")
public class FlowCustomEvent  extends BaseEntity implements Serializable {
    @ApiModelProperty(value = "事件ID")
    @Column(name = "event_id")
    String eventId;

    // * 是全部 内部 外部
    @ApiModelProperty(value = "事件范围")
    @Column(name = "event_range")
    String eventRange;

    @ApiModelProperty(value = "是否异步")
    @Column(name = "is_async")
    Boolean isAsync;

    @ApiModelProperty(value = "事件名称")
    @Column(name = "event_name")
    String eventName;


    @ApiModelProperty(value = "事件优先级")
    @Column(name = "priority")
    Integer priority;

    // * 为无条件执行
    @ApiModelProperty(value = "表达式")
    @Column(name = "expression")
    String expression;

    // 0 为关闭 1 为开启
    @ApiModelProperty(value = "事件开启状态")
    @Column(name = "status")
    Integer status;

    // 执行的JS脚本 --> 操作表单数据 空为不操作
    @ApiModelProperty(value = "执行JS脚本")
    @Column(name = "run_script",columnDefinition = "TEXT")
    String runScript;

    // 不实例化 -->
    @Transient
    String flowWorkId;

    @Transient
    Map<String, Object> eventParams;
}
